package com.restaurant.springboot.entity;

import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Objects;

public class ShoppingCartEntityPK implements Serializable {

    private int userId;
    private int dishesId;

    @Column(name = "user_id")
    @Id
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Column(name = "dishes_id")
    @Id
    public int getDishesId() {
        return dishesId;
    }

    public void setDishesId(int dishesId) {
        this.dishesId = dishesId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShoppingCartEntityPK that = (ShoppingCartEntityPK) o;
        return userId == that.userId &&
                dishesId == that.dishesId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, dishesId);
    }
}
